/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package net.cjb.malacma.rssfeed.entity;

import java.io.Serializable;
import java.util.Calendar;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.PrePersist;
import javax.persistence.Temporal;

/**
 *
 * @author malacma
 */
@Entity
public class Comment implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.TABLE)
    private Long id;

    @Column(nullable = false,length=255,updatable=false)
    private String description;

    @Temporal(javax.persistence.TemporalType.TIMESTAMP)
    private Calendar createdAt;

    public Calendar getDate() {
        return createdAt;
    }

    public void setDate(Calendar date) {
        this.createdAt = date;
    }

    @PrePersist
    private void prePersist(){//Invitialize Calendar date on persist
        this.createdAt = Calendar.getInstance();
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Comment)) {
            return false;
        }
        Comment other = (Comment) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "net.cjb.malacma.rssfeed.entity.Comment[id=" + id + "]";
    }

    @Override
    protected void finalize() throws Throwable {
        super.finalize();
        this.createdAt = null;
        this.description = null;
        this.id = null;
    }


}
